package com.hailong.flink.rpc;

import akka.actor.ActorSystem;
import org.apache.flink.runtime.akka.AkkaUtils;
import org.apache.flink.runtime.rpc.akka.AkkaRpcService;
import org.apache.flink.runtime.rpc.akka.AkkaRpcServiceConfiguration;

import java.util.concurrent.ExecutionException;

/**
 * Created by yuanhailong on 2021/12/18.
 */
public class FlinkRPCClient {
    public static void main(String[] args) throws Exception {

        String address="akka.tcp://flink@192.168.0.101:61328/user/rpc/fa4097fc-8fbe-49c0-aba1-5d8fcdd941d3";


        //step1 创建一个akkaSystem 系统
        ActorSystem defaultActorSystem = AkkaUtils.createDefaultActorSystem();
        AkkaRpcService akkaRpcService = new AkkaRpcService(defaultActorSystem, AkkaRpcServiceConfiguration.defaultConfiguration());

        System.out.println(address);


        //step2 发起远程调用
        GetNowGateway getNowGateway = akkaRpcService.connect(address, GetNowGateway.class).get();
        String now = getNowGateway.getNow();
        System.out.println(now);


    }
}

